package org.excample.controller;

import org.excample.entity.WorkShop;
import org.excample.mapper.WorkshopMapper;
import org.excample.service.WorkShopService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

@RestController//控制层
@RequestMapping("/workshop")
@Validated//支持参数验证注解
public class WorkShopController {
    @Autowired
    private WorkShopService workShopService;
    // 保存车间信息到数据库中
    @PostMapping("/save")
    public ResponseEntity<String> saveWorkshop(@RequestBody WorkShop workshop) {
        WorkShopService.saveWorkShop(workshop);
        return ResponseEntity.ok("保存成功");
    }
    // 更新车间信息到数
    @PutMapping("/update")
    public ResponseEntity<String> updateWorkshop(@PathVariable Long id, @RequestBody WorkShop workshop) {
        WorkShopService.updateWorkshop(id);
        return ResponseEntity.ok("更新成功");
    }

    // 删除车间信息从数据库中

    // 可以根据需要添加其他方法，例如根据ID查询车间信息

    //分页展示：支持前端请求时指定的页码和每页显示的记录数，返回对应页码的车间记录列表。
}
